﻿$ (document).ready(function(){

$ ("#l-head .top-nav").hover(function(){ $ (this).animate({top:"0"}, "fast");   },function(){$ (this).animate({top:"-5px"}, "fast");});

$ ("#body-bg").css({"background-image":"url(http://cimg.178.com/wow/s/i_new/body-bg-"+Math.round(Math.random()*(bgnum-1)+1)+".jpg)"});

	$ ("#hot-event .event-icon").hover(function() {
		$ ("#hot-event .event-title").animate({opacity: "show" , left:"60"}, "slow");
	}, function() {
		$ ("#hot-event .event-title").animate({opacity: "hide" , left:"80"}, "fast");
	});

	$ ("#pics-list img").hover(function(){clearInterval(_play)}, function(){play()});
	
	$ ("#pics-title > li").hover(function(){
							clearInterval(_play);
							_num = $ ("#pics-title > li").index(this);
							change(_num);
										}, function(){play()});
	
    play();

$ (".data-content > li").hover(function(){ 
$ (this).css({"background-color":"#000000","background-position":"left -153px"});
}, 
function(){
$ (this).css({"background-color":"#1c1c1c","background-position":"left top"});

});
	
$ ("#classes .class-content").hide();

_dk=true;

$ .each ( [0,1,2,3,4,5,6,7,8,9],function(i){
_class='class_'+i;
_cookies = 'wowclass_'+i;
if($ .cookie(_cookies) == 'open')
{
$ ("#"+_class).show();
$ ("#classes  .class-btn").eq(i).attr("class","class-btn close");
_dk=false;
}
});

if (_dk){show_class(0);}
	
$ (".class-btn").click(function(){
_num = $ ("#classes  .class-btn").index(this);
show_class(_num);
});


_href=true;
$ (".class-top a").mouseover(function(){_href=false ;});
$ (".class-top a").mouseout(function(){_href=true ;});
$ (".class-top").click(function(){
if (_href)
{
_num = $ ("#classes  .class-top").index(this);
show_class(_num);
}
});



$ ('#nav_ul > li').bind('mouseover', tab_open);
$ ('#nav_ul > li').bind('mouseout',  tab_timer);
	
});

var bgnum = 3;
var timeout         = 300;
var closetimer		= 0;
var ddmenuitem      = 0;

function tab_open()
{	tab_canceltimer();
	tab_close();
	ddmenuitem = $ (this).find('ul').eq(0).css('visibility', 'visible');}

function tab_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function tab_timer()
{	closetimer = window.setTimeout(tab_close, timeout);}

function tab_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}
		
function show_class_num(num)
{
$ ("#class_"+num).show();
$ ("#classes  .class-btn").eq(num).attr("class","class-btn close");
}

function show_class(num)
{
_btn = $ ("#classes  .class-btn").eq(num);
_class = $ (_btn).attr("class");
_cookies = 'wowclass_'+_num;

	if (_class=="class-btn open"){
	$ (_btn).attr("class","class-btn close");
	$ ("#classes  .class-content").eq(num).slideToggle(500);
	$ .cookie(_cookies, 'open',{expires:365}); 
	}
	else
	{
	$ (_btn).attr("class","class-btn open");	
	$ ("#classes  .class-content").eq(num).slideToggle(500);
	$ .cookie(_cookies, null ); 
	}

}

document.onclick = tab_close;

var _num = _play = 0;
function play()
{
    _play = setInterval("auto()", 4000);
}
function change(num)
{
    $ ("#pics-title > li").attr('class','').eq(num).attr('class','select').blur();
    $ ("#pics-list img").hide().eq(num).fadeIn('slow');
}
function auto()
{    
    _num = _num > 2 ? 0 : _num + 1;
    change(_num);
}



function bookmark( label , url) {
    if (document.all)
    {
        window.external.addFavorite(url, label);
    }
    else if (window.sidebar)
    {
        window.sidebar.addPanel(label, url, '');
    }
}
